package com.example.exception;

/**
 * 统一异常
 */
public class ImoocMallException extends RuntimeException {
    private  final Integer code;
    private  final  String message;

    public ImoocMallException(Integer code, String message){
        this.code=code;
        this.message=message;
    }
//    枚举构造成异常
    public ImoocMallException(ImoocMallExceptionEnum exceptionEnum){
//        super(exceptionEnum.getMsg());
//        this.code=exceptionEnum.getCode();
        this(exceptionEnum.getCode(),exceptionEnum.getMsg());
    }


    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
